package com.baseweb.webadmin.core.constants;

import java.util.ArrayList;
import java.util.List;

public enum IsEnableType {
    NORMAL(1,"启用"), DELETE(-1,"禁用");

    private int code;
    private String name;
    IsEnableType(int code, String name){
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static List<IsEnableType> getAllEnum(){
        List<IsEnableType> result = new ArrayList<IsEnableType>();
        for (IsEnableType current : IsEnableType.values())
        {
            result.add(current);
        }
        return result;
    }
    public static IsEnableType getNameByCode(int code){
        List<IsEnableType> allData = getAllEnum();
        for (IsEnableType cur : allData){
            if (cur.getCode() == code){
                return cur;
            }
        }
        return null;
    }
    public static List<String> getTypeOpt() {
        List<String> list = new ArrayList<>();
        for (IsEnableType current : IsEnableType.values()) {
            String string = current.getCode() + ";" + current.getName();
            list.add(string);
        }
        return list;
    }
}
